const app = getApp();
import LoginStore from '../../pages/login/store.js';
import { reqHeader, isAuthorization, banPNG } from '../../utils/util.js';
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    IPhoneX: app.globalData.isIphoneX
  },

  /**
   * 组件的方法列表
   */
  methods: {
    toFirstPage:function(){
      wx.reLaunch({
        url: '/pages/contestList/contestList',
      });
    },
    toUserInfo:function(e){
      if (!isAuthorization(e)) {
        return;
      }
      LoginStore.validateLogin(() => {
        let userId = LoginStore.userInfo.userId;
        let urlStr = '/pages/userInfo/userInfo?userId=' + userId;

        wx.reLaunch({
          url: urlStr
        });

      });
    },
    _submitAction:function(e){
      if (!isAuthorization(e)) {
        return;
      }
      LoginStore.validateLogin(() => {
        wx.chooseImage({
          count: 1,
          sizeType: ['original'],
          sourceType: ['album', 'camera'],
          success: function (res) {
            var path = res.tempFilePaths;
            if (!banPNG(path)) {
              return;
            }
            //上传
            wx.navigateTo({
              url: `/pages/editPhoto/editPhoto?filePath=${path[0]}`
            });
          }
        })

      });
      
    }
  }
})
